package com.example.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RefreshScope
@Slf4j
@RequestMapping
@RestController
public class ConfigCenterController {

    @Value("${configserver.uname:}")
    private String name;

    @Autowired
    private Environment environment;


    @GetMapping("/config")
    public String config() {
        log.info("======== config : {}", name);
        String property = environment.getProperty("configserver.uname");
        log.info("======== config property: {}", property);
        return property;
    }


}
